﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Questionary.Views.Edit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>题目序号</td><td><asp:TextBox ID="txtIdx" runat="server"></asp:TextBox></td>
            </tr>

            <tr>
                <td>题目描述</td><td><asp:TextBox ID="txtDesc" runat="server"></asp:TextBox></td>
            </tr>

            <tr><td>题目类型</td>
                <td>
                    <input type="radio" group="qType" name="qType" id="rdSingle" value="0" runat="server" onclick="OnQtypeChanged(0)" checked /><label for="rdSingle">单选</label>
                    <input type="radio" group="qType" name="qType" id="rdMulti" value="1" runat="server" onclick="OnQtypeChanged(1)"/><label for="rdMulti">多选</label>
                    <input type="radio" group="qType" name="qType" id="rdText" value="2" runat="server" onclick="OnQtypeChanged(2)"/><label for="rdText">主观题</label>
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <div id="selectionDiv">
                        选项:<br /><br />
                        1.<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/>
                        2.<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br/>
                        3.<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br/>
                        4.<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br/>
                        5.<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br/>
                        6.<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox><br/>
                        7.<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox><br/>
                        8.<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox><br/>
                    </div>
                </td>
            </tr>

            <%--<%if(EditType == 1){%>
            <tr><td colspan="2"><asp:CheckBox ID="cbbMulti" runat="server" Text="是否多选"/></td></tr>

            <tr>
                <td>选项</td><td></td>
            </tr>

            <tr><td colspan="2"><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox5" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox7" runat="server"></asp:TextBox></td></tr>
            <tr><td colspan="2"><asp:TextBox ID="TextBox8" runat="server"></asp:TextBox></td></tr>
            <%} %>--%>

              <td colspan="2" style="padding-left:20px;">
                   <asp:Button ID="btnSaveItem" runat="server" Text="保存" OnClientClick="return validate();" OnClick="btnSaveItem_Click" />&nbsp;&nbsp;<input type="button" value="取消" onclick="javascript: window.history.back()" />
               </td>
        </table>
    </div>
    </form>
    <script>
        function OnQtypeChanged(opt) {
            if (opt == 2) {
                document.getElementById("selectionDiv").style.display = "none";
            }
            else {
                document.getElementById("selectionDiv").style.display = "";
            }
        }

        function CheckQType() {
            if (document.getElementById("rdText").checked) {
                OnQtypeChanged(2);
            }
        }
        CheckQType();

        function validate() {
            var idx = document.getElementById("txtIdx").value;
            if (!/\d+/.test(idx)) {
                alert("题目序号请填入数字");
                return false;
            }
            return true;
        }
    </script>
</body>
</html>
